<?php
//设置cookie 名子为bgcolor 1个小时
setcookie('bgcolor', 'purple', time() + 3600);//1小时
setcookie('name', '张三丰', time() + (3600 * 24)); //cookie 有效期为1天
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>webrx</title>
    <style>
        body {
            /* $_COOKIE['bgcolor'] 读取cookie值*/
            background-color: <?=$_COOKIE['bgcolor']?>;
        }
    </style>
</head>
<body>
<pre>

<?php
//删除cookie name
setcookie('name', '', -1);

print_r($_COOKIE);
?>
</pre>
</body>
</html>
